package com.itheima.object.homework.Test2;

/*2、【编号：702】 请定义教师类（Teacher），属性包括姓名和工号。要求分别使用空参和有参构造方法创建对象，
        空参创建的对象通过setXxx赋值，有参创建的对象直接赋值。定义教课（teach）方法，输出“工号为xxx的xxx老师正在讲课”。*/
public class Teacher {
    private String name;
    private int number;

    public Teacher() {
    }

    public Teacher(String name, int number) {
        this.name = name;
        this.number = number;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void show() {
        System.out.println(name + " " + number);
    }
    public void teach(String name, int number){
        System.out.println("工号为"+number+"的"+name+"老师正在讲课");
    }
}

class TestTescher {
    public static void main(String[] args) {
        Teacher tea1 = new Teacher();
        tea1.setName("诺言");
        tea1.setNumber(1001);
        tea1.show();
        tea1.teach("诺言",1001);

        Teacher tea2 = new Teacher("简自豪", 1007);
        tea2.show();
    }
}
